package cn.schoolwow.quickdao.test.module.business.user.ddl.flow.column;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.domain.entity.Property;
import cn.schoolwow.quickdao.domain.entity.PropertyOption;
import cn.schoolwow.quickdao.test.entity.User;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import org.junit.Assert;

public class CheckCreateNumberColumnResultFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);
        PropertyOption numberPropertyOption = (PropertyOption) flowContext.checkData("numberPropertyOption");

        Property numberProperty = dao.getProperty(User.class, "number");
        Assert.assertEquals(numberPropertyOption.column, numberProperty.column);
        Assert.assertTrue(numberPropertyOption.columnType.contains(numberProperty.columnType));
        Assert.assertEquals(numberPropertyOption.notNull, numberProperty.notNull);
    }

    @Override
    public String name() {
        return "检查用户表新增工号字段结果";
    }
}
